<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Home</title>

    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">

    <h1 class="page-title">Home</h1>

    



    


    <h3> </h3>










    




    <section>
        <article><p align="center" style="text-align: center"><img src="https://raw.githubusercontent.com/ethanent/phin/master/media/phin-textIncluded.png" width="250" alt="phin logo"/></p>

<hr>
<blockquote>
<p>The ultra-lightweight Node.js HTTP client</p>
</blockquote>
<p><a href="https://ethanent.github.io/phin/">Full documentation</a> | <a href="https://github.com/ethanent/phin">GitHub</a> | <a href="https://www.npmjs.com/package/phin">NPM</a></p>
<h2>Simple Usage</h2><pre class="prettyprint source lang-javascript"><code>const p = require('phin')

const res = await p('https://ethanent.me')

console.log(res.body)</code></pre><p>Note that the above should be in an async context! phin also provides an unpromisified version of the library.</p>
<h2>Install</h2><pre class="prettyprint source"><code>npm install phin</code></pre><h2>Why phin?</h2><p>phin is <strong>trusted</strong> by some really important projects. The hundreds of contributors at <a href="https://github.com/less/less.js">Less</a>, for example, depend on phin as part of their development process.</p>
<p>Also, phin is super <strong>lightweight</strong>. Like <strong>99.8% smaller than request</strong> lightweight. To compare to other libraries, see <a href="https://github.com/ethanent/phin/blob/master/README.md#phin-vs-the-competition">phin vs. the Competition</a>.</p>
<p><img src="https://pbs.twimg.com/media/DSPF9TaUQAA0tIe.jpg:large" alt="phin became 33% lighter with release 2.7.0!"/></p>
<h2>Quick Demos</h2><p>Simple POST:</p>
<pre class="prettyprint source lang-js"><code>await p({
    url: 'https://ethanent.me',
    method: 'POST',
    data: {
        hey: 'hi'
    }
})</code></pre><h3>Unpromisified Usage</h3><pre class="prettyprint source lang-js"><code>const p = require('phin').unpromisified

p('https://ethanent.me', (err, res) => {
    if (!err) console.log(res.body)
})</code></pre><p>Simple parsing of JSON:</p>
<pre class="prettyprint source lang-js"><code>// (In async function in this case.)

const res = await p({
    'url': 'https://ethanent.me/name',
    'parse': 'json'
})

console.log(res.body.first)</code></pre><h3>Default Options</h3><pre class="prettyprint source lang-js"><code>const ppostjson = p.defaults({
    'method': 'POST',
    'parse': 'json',
    'timeout': 2000
})

// In async function...

const res = await ppostjson('https://ethanent.me/somejson')
// ^ An options object could also be used here to set other options.

// Do things with res.body?</code></pre><h3>Custom Core HTTP Options</h3><p>phin allows you to set <a href="https://nodejs.org/api/http.html#http_http_request_url_options_callback">core HTTP options</a>.</p>
<pre class="prettyprint source lang-js"><code>await p({
    'url': 'https://ethanent.me/name',
    'core': {
        'agent': myAgent // Assuming you'd already created myAgent earlier.
    }
})</code></pre><h2>Full Documentation</h2><p>There's a lot more which can be done with the phin library.</p>
<p>See <a href="https://ethanent.github.io/phin/">the phin documentation</a>.</p>
<h2>phin vs. the Competition</h2><p>phin is a very lightweight library, yet it contains all of the common HTTP client features included in competing libraries!</p>
<p>Here's a size comparison table:</p>
<table>
<thead>
<tr>
<th>Package</th>
<th>Size</th>
</tr>
</thead>
<tbody>
<tr>
<td>request</td>
<td><a href="https://packagephobia.now.sh/result?p=request"><img src="https://packagephobia.now.sh/badge?p=request" alt="request package size"></a></td>
</tr>
<tr>
<td>superagent</td>
<td><a href="https://packagephobia.now.sh/result?p=superagent"><img src="https://packagephobia.now.sh/badge?p=superagent" alt="superagent package size"></a></td>
</tr>
<tr>
<td>isomorphic-fetch</td>
<td><a href="https://packagephobia.now.sh/result?p=isomorphic-fetch"><img src="https://packagephobia.now.sh/badge?p=isomorphic-fetch" alt="isomorphic-fetch package size"></a></td>
</tr>
<tr>
<td>axios</td>
<td><a href="https://packagephobia.now.sh/result?p=axios"><img src="https://packagephobia.now.sh/badge?p=axios" alt="axios package size"></a></td>
</tr>
<tr>
<td>got</td>
<td><a href="https://packagephobia.now.sh/result?p=got"><img src="https://packagephobia.now.sh/badge?p=got" alt="got package size"></a></td>
</tr>
<tr>
<td>r2</td>
<td><a href="https://packagephobia.now.sh/result?p=r2"><img src="https://packagephobia.now.sh/badge?p=r2" alt="r2 package size"></a></td>
</tr>
<tr>
<td>node-fetch</td>
<td><a href="https://packagephobia.now.sh/result?p=node-fetch"><img src="https://packagephobia.now.sh/badge?p=node-fetch" alt="node-fetch package size"></a></td>
</tr>
<tr>
<td>snekfetch</td>
<td><a href="https://packagephobia.now.sh/result?p=snekfetch"><img src="https://packagephobia.now.sh/badge?p=snekfetch" alt="snekfetch package size"></a></td>
</tr>
<tr>
<td>phin</td>
<td><a href="https://packagephobia.now.sh/result?p=phin"><img src="https://packagephobia.now.sh/badge?p=phin" alt="phin package size"></a></td>
</tr>
</tbody>
</table></article>
    </section>






</div>

<nav>
    <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#phin">phin</a></li></ul>
</nav>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Mon Jun 03 2019 19:40:29 GMT-0700 (Pacific Daylight Time)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>